﻿@model Model.Commodity
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    body {
        font-family: 'Literata', serif;
    }

    section {
        height: 100vh;
    }

 

    [data-product-detail] {
        width: 90%;
        height: 400px;
        margin: 0 auto;
        position: relative;
        top: 200px;
        background: white;
        box-shadow: 2px 2px 7px rgba(0,0,0,0.3);
        display: flex;
        justify-content: center;
        align-items: center;
    }

        [data-product-detail] .img-card {
            width: 40%;
            height: 80%;
            border: 1px solid lightgrey;
            border-radius: 5px;
        }

    .img-card .img {
        height: 80%;
        display: flex;
        flex-direction: column;
    }

        .img-card .img i {
            color: skyblue;
            margin-left: 21em;
            margin-top: 10px;
        }

        .img-card .img img {
            width: 70%;
            height: 200px;
            position: relative;
            left: 60px;
            top: 20px;
        }

    .img-card .img-options {
        border-top: 1px solid lightgrey;
    }

    [data-product-detail] .product-details {
        height: 80%;
        width: 50%;
        /*   border: 1px solid teal; */
        padding-left: 20px;
    }

    .product-details h2 {
        margin: 0;
        font-size: 35px;
    }

    .product-details p:first-of-type {
        margin: 0;
    }

    .product-details p:nth-of-type(2) {
        border: 1px solid lightgrey;
        width: 140px;
        height: 25px;
        padding-left: 5px;
    }

        .product-details p:nth-of-type(2) span {
            font-size: 12px;
            position: relative;
            bottom: 1px;
        }

    .product-details p:nth-of-type(3) {
        color: grey;
        margin-bottom: 0;
    }

    .product-details p:nth-of-type(4) {
        margin-top: 0;
    }

        .product-details p:nth-of-type(4) span:first-of-type {
            font-weight: 800;
            font-size: 25px;
            margin-right: 10px;
        }

        .product-details p:nth-of-type(4) span:nth-of-type(2) {
            text-decoration: line-through;
        }

        .product-details p:nth-of-type(4) span:nth-of-type(3) {
            color: teal;
            font-size: 17px;
            margin-left: 10px;
        }

    .product-details p:nth-of-type(5) {
        color: grey;
        font-size: 14px;
    }

    .product-details i.fas {
        color: #FFC107;
        margin-right: 5px;
    }

    .sample-colors {
        display: flex;
    }

        .sample-colors div {
            width: 30px;
            height: 25px;
            /*   border: 1px solid grey; */
        }

            .sample-colors div:first-of-type {
                margin-right: 15px;
                background: maroon;
            }

                .sample-colors div:first-of-type div {
                    background: maroon;
                    width: 10px;
                    height: 10px;
                    transform: translate(22px, -5px);
                    border-radius: 50%;
                    border: 2px solid white;
                }

            .sample-colors div:not(:first-of-type) {
                background: teal;
                margin: 0 15px;
            }

    button {
        width: 170px;
        height: 35px;
        border: none;
        margin-top: 14px;
        font-family: 'Literata', serif;
    }

        button:first-of-type {
            background: #4FC3F7;
            border-radius: 4px;
            margin-right: 10px;
        }

        button:nth-of-type(2) {
            background: white;
            border: 2px solid #4FC3F7;
            border-radius: 4px;
        }

    .img-options {
        display: flex;
        padding-left: 10px;
    }

        .img-options div {
            border: 1px solid lightgrey;
            margin: 10px 20px;
            width: 40px;
            height: 40px;
        }

            .img-options div img {
                width: 80%;
                margin: 7px 4px;
            }

            .img-options div:nth-of-type(2) img {
                transform: rotate(90deg);
            }

            .img-options div:nth-of-type(3) img {
                transform: rotate(-45deg);
            }

            .img-options div:nth-of-type(4) img {
                transform: rotate(45deg);
            }

    sections {
        width: 128px;
        display: flex;
        margin: 50px auto;
    }

    .spans {
        display: inline-block;
        width: 35px;
        height: 30px;
        background-color: #fff;
        cursor: pointer;
        vertical-align: middle;
        border: 1px solid #999999;
        font-size: 16px;
        font-weight: bolder;
        line-height: 28px;
    }

    input {
        width: 58px;
        height: 30px;
        padding: 1px 0;
        border: 1px solid #999999;
        border-left: none;
        border-right: none;
    }

        /*  取消右侧加减按钮解决方法 */
        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
        }
</style>
<style>
	import url(//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css);

.detailBox {
    width:320px;
    border:1px solid #bbb;
    margin:50px;
}
.titleBox {
    background-color:#fdfdfd;
    padding:10px;
}
.titleBox label{
  color:#444;
  margin:0;
  display:inline-block;
}

.commentBox {
    padding:10px;
    border-top:1px dotted #bbb;
}
.commentBox .form-group:first-child, .actionBox .form-group:first-child {
    width:80%;
}
.commentBox .form-group:nth-child(2), .actionBox .form-group:nth-child(2) {
    width:18%;
}
.actionBox .form-group * {
    width:100%;
}
.taskDescription {
    margin-top:10px 0;
}
.commentList {
    padding:0;
    list-style:none;
    max-height:200px;
    overflow:auto;
}
.commentList li {
    margin:0;
    margin-top:10px;
}
.commentList li > div {
    display:table-cell;
}
.commenterImage {
    width:80px;
    margin-right:5px;
    height:100%;
    float:left;
}
.commenterImage img {
    width:100%;
    border-radius:50%;
}
.commentText p {
    margin:0;
    font-size:26px;
}
.sub-text {
    color:#aaa;
    font-family:verdana;
    font-size:16px;
}
.actionBox {
    border-top:1px dotted #bbb;
    padding:10px;
}
</style>
<body>
    <section class="sections">
        <header>
            <h1>Tibo Shopping Goods</h1>
            <h3>Welcome to the shop of<br>@Model.bussiness!.Name</h3>
        </header>
        <div data-product-detail>
            <div class="img-card">
                <div class='img'>
                    <i class="far fa-heart"></i>
                    <img src=@Model.Imgs />
                </div>
            </div>
            <div class="product-details">
                <h2>@Model.Name</h2>
                <p>@Model.Describe</p>
                <br>
                Price:
                <p><span>@Model.Price 元</span></p>
                <p><span>发货地址：@Model.Position</span></p>
                <p><span>库存：@Model.TotalNumber</span></p>
                <p><span>店铺：@Model.bussiness.Name</span></p>
                <form id="formid">
                    <section>
                        <span class="spans" onclick="opera('num', false);">-</span>
                        <input type="number" id="num" name="num" value="1" style="border:solid 2px;">
                        <input type="hidden" id="cid" name="cid" value=@Model.ID />
                        <span class="spans" onclick="opera('num', true);">+</span>
                        <br />
                      
                        
                        @{
                            
                            if (ViewBag.role == 2)
                            {
                                <label>收货地址：</label>

                                <br />
                                <input type="text" id="cid" name="address" style="border:solid 2px;width:300px" />
                                <br>
                               <button onclick="click1()">立刻购买</button>
                               <button onclick="click2()">加入购物车</button>
                            }
                        }
                        
                    </section>

                </form>
                <iframe src="" frameborder="0" name="frameName"></iframe>
            </div>
        </div>
    </section>
</body>
<body>
	<div class="detailBox">
		<div class="titleBox">
		  <label>商品评论</label>
		
		</div>

		<div class="actionBox">
            @{
                foreach(Model.Comment c in Model.comments)
                {
                    <ul class="commentList">
                        <li>
                            <div class="commenterImage">
                                <img src="http://placekitten.com/50/50" />
                            </div>
                            <div class="commentText">
                                <p>用户： @c.user.Name</p>
                                <p class="">@c.Usercomment</p> <span class="date sub-text">@c.date</span>
                            </div>
                        </li>
                    </ul>
                }
            }
		</div>
	</div>
</body>
<script>
    //  input样式修改及绑定左右按钮
    function opera(x, y) {
        var rs = new Number(document.getElementById(x).value);

        if (y) {
            document.getElementById(x).value = rs + 1;

        }
        else if (rs > 0) {
            document.getElementById(x).value = rs - 1;
        }
    }
    function click1() {
        document.getElementById('formid').action = "..\\Order\\BuyNow";
        document.getElementById('formid').method = "get";
        document.getElementById('formid').submit();

    }
    function click2() {
        document.getElementById('formid').action = "..\\Order\\AddToOrder";
        document.getElementById('formid').target = "frameName"
        document.getElementById('formid').method = "get";
        document.getElementById('formid').submit();
        alert("加入购物车成功！");
    }
</script>
</html>